import {request} from '../../request/index'
import regeneratorRuntime from '../../lib/runtime/runtime';
wx-Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperList:[],
    cateList:[],
    floorList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    /* wx.request({
      url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
      success: (result) => {
        console.log(result);
        this.setData({
          swiperList : result.data.message
        })
      }
    }); */
    this.getSwiperList()
    this.getCateList()
    this.getFloorList()
  },
  /* 获取轮播图 数据 */
  /* getSwiperList(){
    request({url: '/home/swiperdata'})
    .then(result=>{
      this.setData({
        swiperList : result
      })
    })
  }, */
  async getSwiperList(){
    const result = await request({url: '/home/swiperdata'})
    this.setData({
      swiperList : result
    })
  },
  /* 获取导航栏 数据 */
  getCateList(){
    request({url: '/home/catitems'})
      .then(result=>{
        this.setData({
          cateList : result
        })
      })
  },
/* 获取楼层 数据 */
getFloorList(){
  request({url: '/home/floordata'})
    .then(result=>{
      result.forEach((v) =>v.product_list.forEach(u=>u.navigator_url=u.navigator_url.replace("?", "/goods_list?")))
      this.setData({
        floorList : result
      })
    })
}
})